package com.xiumu.securitydemo.config.security.handler;

import com.xiumu.securitydemo.model.bean.ResultJSON;
import com.xiumu.securitydemo.utils.SecurityHandlerUtil;
import org.springframework.security.core.Authentication;
import org.springframework.security.web.authentication.AuthenticationSuccessHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

import static com.xiumu.securitydemo.utils.args.ResultArgsUtil.USER_LOGIN_SUCCESS_CODE;
import static com.xiumu.securitydemo.utils.args.ResultArgsUtil.USER_LOGIN_SUCCESS_MSG;

/**
 * @Author xiumu
 * @Date 2020/5/28 10:57
 */
public class LoginSuccessHandlerImpl implements AuthenticationSuccessHandler {
    @Override
    public void onAuthenticationSuccess(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Authentication authentication) throws IOException, ServletException {
        SecurityHandlerUtil.responseHandler(httpServletResponse,new ResultJSON(USER_LOGIN_SUCCESS_CODE,USER_LOGIN_SUCCESS_MSG));
    }
}
